package eg.com.itiga.repositoryimpl.role;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import eg.com.itiga.domain.Role;
import eg.com.itiga.repository.exception.DataException;
import eg.com.itiga.repository.role.RoleDao;
import eg.com.itiga.repositoryimpl.base.BaseDaoImpl;
import eg.com.itiga.repositoryimpl.base.HibernateUtil;

public class RoleDaoImpl extends BaseDaoImpl implements RoleDao{

	
	public Role getRoleByName(String name)  throws DataException{
		Session session = HibernateUtil.getCurrentSession();
		try {
			Query q=session.createQuery("from Role r where r.RName like '"+name+"'");
			return (Role)q.uniqueResult();
		} catch (HibernateException e) {
			throw new DataException("Data Exception");
		}
	}

}
